<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>修改部件</title>
    <meta name="context-path" th:content="@{/}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/bootstrap.min.css}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/bootstrap-responsive.min.css}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/colorpicker.css}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/datepicker.css}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/uniform.css}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/select2.css}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/matrix-style.css}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/matrix-media.css}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/matrix-full.css}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/font-awesome/css/font-awesome.css}"/>
    <link rel="stylesheet" th:href="@{/resources/valid/css/bootstrapValidator.css}"/>
    <link rel="stylesheet" th:href="@{/resources/layui/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/resources/css/website.css}"/>
</head>
<body class="childbody">
<div class="container-fluid editform_fluid" xmlns:th="http://www.thymeleaf.org">
    <!--Chart-box-->
    <div class="row-fluid">
        <div class="widget-box">
            <div class="widget-title"><span class="icon"> <i class="icon-align-justify"></i> </span>
                <h5>修改部件</h5>
            </div>
            <div class="widget-content">
                <form id="detailform" class="form-horizontal" th:object="${entity}">
                    <input type="hidden" id="id" name="id" th:value="*{id}"/>
                    <div class="control-group">
                        <label class="control-label">名称 :</label>
                        <div class="controls  form-group">
                            <input type="text" name="name" th:value="*{name}" class="span11 form-control"
                                   placeholder="请输入名称">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">编码：</label>
                        <div class="controls form-group">
                            <input type="text" name="code" th:value="*{code}" class="span11 form-control"
                                   placeholder="请输入编码">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">类别：</label>
                        <div class="controls form-group">
                            <select id="cbbCategory" class="span11 form-control" name="category">
                                <option value="" th:selected="${entity.category == ''}">---请选择---</option>
                                <option th:each="cate : ${categorys}" th:value="${cate.id}"
                                        th:text="${cate.name}" th:selected="${entity.category == cate.id}"></option>
                            </select>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">图片：</label>
                        <div class="controls form-group">
                            <table style="width: 100%">
                                <tr>
                                    <td width="50%">
                                        <div style="position:relative">
                                            <img id="imgAlt1" class="cover-radius"
                                                 width="100%" style="cursor: pointer;height:150px;"/>
                                            <input id="image1" name="image1" type="hidden"/>
                                            <input id="fileInput_image1" name="file" type="file"
                                                   style="position: absolute; left: 0px; top: 0px; width: 100%; height: 100%; opacity: 0; cursor: pointer;"/>
                                            <small class="help-block cover-tips" style="color: #dd4b39;display: none;">
                                                请上传照片
                                            </small>
                                        </div>
                                    </td>
                                    <td width="50%">
                                        <div style="position:relative">
                                            <img id="imgAlt2" class="cover-radius"
                                                 width="100%" style="cursor: pointer;height:150px;"/>
                                            <input id="image2" name="image2" type="hidden"/>
                                            <input id="fileInput_image2" name="file" type="file"
                                                   style="position: absolute; left: 0px; top: 0px; width: 100%; height: 100%; opacity: 0; cursor: pointer;"/>
                                            <small class="help-block cover-tips" style="color: #dd4b39;display: none;">
                                                请上传照片
                                            </small>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td width="50%">
                                        <div style="position:relative">
                                            <img id="imgAlt3" class="cover-radius"
                                                 width="100%" style="cursor: pointer;height:150px;"/>
                                            <input id="image3" name="image3" type="hidden"/>
                                            <input id="fileInput_image3" name="file" type="file"
                                                   style="position: absolute; left: 0px; top: 0px; width: 100%; height: 100%; opacity: 0; cursor: pointer;"/>
                                            <small class="help-block cover-tips" style="color: #dd4b39;display: none;">
                                                请上传照片
                                            </small>
                                        </div>
                                    </td>
                                    <td width="50%">
                                        <div style="position:relative">
                                            <img id="imgAlt4" class="cover-radius"
                                                 width="100%" style="cursor: pointer;height:150px;"/>
                                            <input id="image4" name="image4" type="hidden"/>
                                            <input id="fileInput_image4" name="file" type="file"
                                                   style="position: absolute; left: 0px; top: 0px; width: 100%; height: 100%; opacity: 0; cursor: pointer;"/>
                                            <small class="help-block cover-tips" style="color: #dd4b39;display: none;">
                                                请上传照片
                                            </small>
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">经度：</label>
                        <div class="controls form-group">
                            <input type="text" name="longitude" th:value="*{longitude}" class="span11 form-control"
                                   placeholder="请输入经度">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">纬度：</label>
                        <div class="controls form-group">
                            <input type="text" name="latitude" th:value="*{latitude}" class="span11 form-control"
                                   placeholder="请输入纬度">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">描述：</label>
                        <div class="controls form-group">
                            <textarea class="span11 form-control" name="description"
                                      th:text="*{description}"></textarea>
                        </div>
                    </div>
                    <div id="myCategories">

                    </div>
                    <div class="form-actions">
                        <button id="btnSubmit" type="button" class="btn btn-success">确定</button>
                        <button id="btnClose" type="reset" class="btn btn-primary">重置</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script th:src="@{/resources/js/jquery.min.js}"></script>
<script th:src="@{/resources/js/jquery-migrate-1.2.1.js}"></script>
<script th:src="@{/resources/matrix/js/jquery.ui.custom.js}"></script>
<script th:src="@{/resources/matrix/js/bootstrap.min.js}"></script>
<script th:src="@{/resources/matrix/js/bootstrap-colorpicker.js}"></script>
<script th:src="@{/resources/matrix/js/bootstrap-datepicker.js}"></script>
<script th:src="@{/resources/matrix/js/masked.js}"></script>
<script th:src="@{/resources/matrix/js/jquery.uniform.js}"></script>
<script th:src="@{/resources/matrix/js/select2.min.js}"></script>
<script th:src="@{/resources/matrix/js/matrix.js}"></script>
<script th:src="@{/resources/matrix/js/jquery.peity.min.js}"></script>
<script th:src="@{/resources/layui/layui.all.js}" charset="utf-8"></script>
<script th:src="@{/resources/valid/js/bootstrapValidator.js}"></script>
<script th:src="@{/resources/valid/js/language/zh_CN.js}"></script>
<script th:src="@{/resources/js/website.js}"></script>
<script th:src="@{/resources/js/system.js}"></script>
<script th:src="@{/resources/js/validation_fields.js}"></script>
<script th:src="@{/resources/js/monitor/monitor_tree.js}"></script>
<script th:src="@{/resources/js/monitor/monitor_tree_common.js}"></script>
<script th:src="@{/resources/uploader/AjaxFileUpload/ajaxfileupload.js}"></script>
<script th:src="@{/resources/js/upload.js}"></script>
<script th:inline="javascript">
    /*<![CDATA[*/
    layui.use(['form', 'layer', 'table'], function () {
        var formEdit = new TreeFormEdit(layui.form, layui.layer, editPart, {
            url: contextRoot + "part/doUpdatePart",
            getData: function () {
                return $("#detailform").serializeArray();
            }
        }, "detailform", ValidFields.Device);
        $("#btnSubmit").bind("click", function (event) {
            formEdit.submit();
        });
        $("#btnClose").bind("click", function (event) {
            formEdit.close();
        });
        $('#cbbCategory').on('change', function () {
            if ($(this).val()) {
                var val = $(this).val();
                loadDetailCategories("myCategories", "part", val, $("#id").val());
            }
        });

        $('#cbbCategory').trigger('change');

        var paths = new Array();
        paths.push([[${entity.image1}]]);
        paths.push([[${entity.image2}]]);
        paths.push([[${entity.image3}]]);
        paths.push([[${entity.image4}]]);
        for (var i = 1; i < paths.length + 1; i++) {
            if (paths[i - 1] && paths[i - 1].length < 1) {
                new ImageFileUpload(null, "fileInput_image" + i, "imgAlt" + i, "image" + i);
            }
            else {
                new ImageFileUpload(paths[i - 1], "fileInput_image" + i, "imgAlt" + i, "image" + i);
            }
        }
    });
    /*]]>*/
</script>
</body>
</html>